package acs.util;

import acs.collection.Params;
import acs.constant.Constant;
import acs.constant.EventType;
import acs.controller.MessageQueue;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * ???????
 * @author Administrator
 *
 */
public class DbUtil {
	private static DbUtil instance =new DbUtil();
	public static DbUtil getInstance() {
		return instance;
	}
	
	String key="xiao";
	public void loadOffer(Params params){
		loadOffer(params.get("duration"),params.get("timeUnit"));
	}
	public void loadOffer(int duration,TimeUnit timeUnit){
		try {
			Thread.sleep(2*1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		switch (timeUnit) {
		case HOURS:
			System.out.println("查询 "+duration+" 小时前的数据");
			break;
		case MINUTES:
			System.out.println("查询 "+duration+" 分前的数据");
			break;
		case SECONDS:
			System.out.println("查询 "+duration+" 秒前的数据");
			break;
		default:
			System.out.println("查询 "+duration+" 天前的数据");
			break;
		}
		Map<String, Object> result=new HashMap<String, Object>();
		result.put(Constant.CACHE_KEY, "小苏"+timeUnit);
		Params param=new Params();
		param.put(Constant.TRANSFER_OFFER, result);
		MessageQueue.getInstance().putMessage(EventType.RESPONSE_FOR_QUERY_CACHE, param);
	}

	public static void main(String[] args) {
		System.out.println(TimeUnit.SECONDS);
		System.out.println(TimeUnit.HOURS);
	}
}
